﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    /// <summary>
    /// 信息权限 逻辑类
    /// </summary>
    public class DocClsAuthority
    {
        private DAL.DocClsAuthority docClsAuthorityDAL = new DAL.DocClsAuthority();
        /// <summary>
        /// 构造函数
        /// </summary>
        public DocClsAuthority()
        {
        }
        /// <summary>
        /// 获取信息类别的权限数据
        /// <creator>wangl</creator>
        /// <date>2013-08-01</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="docClsCd">信息类别编号</param>
        /// <returns>信息类别权限列表</returns>
        public List<Model.DocClsAuthority> GetListByClsCd(string entityNo, string docClsCd)
        {
            DataSet ds = docClsAuthorityDAL.GetListByClsCd(entityNo,docClsCd);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得某个用户在某类别上有发布权限的所有部门
        /// <creator>wangl</creator>
        /// <date>2013-08-01</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="emplNo">员工编号</param>
        /// <param name="docClsCd">信息编号</param>
        /// <returns>DataSet对象</returns>
        public DataTable GetDeptInDodAuthority(string entityNo, string emplNo, string docClsCd)
        {
            DataSet ds= docClsAuthorityDAL.GetDeptInDodAuthority(entityNo, emplNo, docClsCd);
            return ds.Tables[0];
        }
        /// <summary>
        /// 获得某个用户在某类别上有发布权限的所有工作组
        /// <creator>wangl</creator>
        /// <date>2013-08-01</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="emplNo">员工编号</param>
        /// <param name="docClsCd">信息编号</param>
        /// <returns>DataSet对象</returns>
        public DataTable GetGroupInDodAuthority(string entityNo, string emplNo, string docClsCd)
        {
            DataSet ds = docClsAuthorityDAL.GetGroupInDodAuthority(entityNo, emplNo, docClsCd);
            return ds.Tables[0];
        }
        /// <summary>
        /// 获得数据列表
        /// <creator>wangl</creator>
        /// <date>2013-08-01</date>
        /// </summary>
        /// <param name="dt">DataTable对象</param>
        /// <returns>信息类别权限列表</returns>
        private List<ElingOA6_Admin_DSJCJ.Model.DocClsAuthority> DataTableToList(DataTable dt)
        {
            List<ElingOA6_Admin_DSJCJ.Model.DocClsAuthority> modelList = new List<ElingOA6_Admin_DSJCJ.Model.DocClsAuthority>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_Admin_DSJCJ.Model.DocClsAuthority model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = docClsAuthorityDAL.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
    }
}
